/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-11-13
 * Time: 14:30
 */
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        long[] prefixSum = new long[n+1];
        for(int i = 1; i <= n; i++) {
            prefixSum[i] = prefixSum[i-1] + a[i-1];
        }

        long[] expe = new long[q];
        for(int j = 0; j < q; j++) {
            int x = in.nextInt();
            int y = in.nextInt();
            expe[j] = prefixSum[y] - prefixSum[x-1];
        }

        for(long x : expe) {
            System.out.println(x);
        }
    }
}

